onLoad: function() {
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo( function( userInfo ) {
      //更新数据
      that.setData( {
        userInfo: userInfo
      })
    })
  }

  var app = getApp()

  <!--index.wxml-->
<view class="container">
  <view  bindtap="bindViewTap" class="userinfo">
    <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
    <text class="userinfo-nickname">{{userInfo.nickName}}</text>
  </view>
  <view class="usermotto">
    <text class="user-motto">{{motto}}</text>
  </view>
</view>

//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    motto: 'Hello World',
    userInfo: {}
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  }
})

function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()


  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}

module.exports = {
  formatTime: formatTime
}



<view class="container">

<view class="news" wx:for="{{news}}" wx:for-item="new">
    <view class="news-box {{new.type}}" bindtouchstart="touchS" bindtouchmove="touchM" bindtouchend="touchE" 
          style="{{new.scrollStyle}}" data-id="{{index}}">
        <view class="header">
            <text class="title">{{new.title}}</text>
            <text class="time">{{new.time}}</text>
        </view>
        <view class="body">
            <text>{{new.body}}</text>
        </view>
    </view>
    <view class="del-box">
        <text class="del-btn" style="width:{{btnWidth}}rpx" bindtap="delMessage" data-id="{{index}}">删除</text>
    </view>
  </view>

  <view class="end">--EOF--</view>
</view>


.news{
    width: 100%;
    position: relative;
    height:186rpx;
    border-bottom: 0.1rpx solid #ddd;
}
.news-box{
    width: 100%;
    background: #fff;
    position: absolute; 
}
.news-box:before{
    content: "";
    width: 90rpx;
    height: 90rpx;
    border-radius: 45rpx;
    display: inline-block;
    position: absolute;
    top:38rpx;
    left:20rpx;
    background: rgba(254, 156, 107,0.9) url('../../images/system/iconfont-warning.png') no-repeat center center;
}
.news-box.system:before{
    background: rgba(255, 174, 59,0.9) url('../../images/system/iconfont-notice.png') no-repeat center center;
}

.news-box .header{
    display: flex;
    margin-bottom: 6rpx;
    margin:20rpx 20rpx 20rpx 130rpx;
    justify-content: space-between;
}
.news-box .header .time{
    font-size:0.7rem;
    color:#999;
}
.news-box .body{
    margin:0rpx 20rpx 20rpx 130rpx;
}
.news-box .body text{
    color:#666;
    font-size:0.75rem;
}
.del-box{
    display: flex;
    height: 100%;
    justify-content:flex-end;
}
.del-box .del-btn{
    font-size:1rem;
    display: inline-block;
    align-self:flex-end;
    line-height: 186rpx;
    color:#fff;
    text-align: center;
    background:#F41B0A;
}

.end{
    color:#ccc;
    font-style: italic;
}



// pages/myNotices/myNotices.js
Page({
  data:{
    startX:0,
    lastX:0,
    btnWidth:190,
    news:[{
      index:0,
      type:'',
      title:'临近租期提醒',
      time:'今天 20:10',
      body:'尊敬的客户，您在恒生科技园13号楼418室的租用将在5天后到期，请及时续期。',
      scrollStyle:'',
    },{
      type:'system',
      title:'卡券到期提醒',
      time:'03.11 18:47',
      body:'尊敬的客户，您有一张价值50元卡券即将到期，点击使用。',
      scrollStyle:'',
    }]
  },
  onLoad:function(options){
    
  },
  touchS:function(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    if(e.touches.length==1){
      this.setData({
        startX:e.touches[0].clientX    ///记录触摸起始位置的X坐标
      });
    }
  },
  touchM:function(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    var news = that.data.news;
    if(e.touches.length==1){
      var moveX = e.touches[0].clientX;
      var disX = that.data.lastX + that.data.startX - moveX;
      disX = disX > that.data.btnWidth ? that.data.btnWidth : disX;
      that.data.lastX = disX;
      var scrollStyle = 'left:-'+disX+'rpx';
      news[id].scrollStyle = scrollStyle
      that.setData({news:news});
    }
  },
  touchE:function(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    if(e.changedTouches.length==1){
      var endX = e.changedTouches[0].clientX;
      var disX = that.data.startX - endX;
      var btnWidth = that.data.btnWidth;
    }
  },
  delMessage:function(e){
    var id = e.currentTarget.dataset.id;
    var news = this.data.news;

    delete news[id];
    console.log(news)
    this.setData({
      news:news
    });
  }
})